package com.zorn.platform.user.controller;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zorn.core.spring.mvc.support.ControllerSupport;
import com.zorn.platform.user.service.IUserComponentService;

@Controller
@Scope("prototype")
@RequestMapping("/user/component")
public class UserComponentController extends ControllerSupport {

	/* Fields
	================================================== */
	@Autowired
	private IUserComponentService userComponentService;

	/* Methods
	================================================== */
	@ResponseBody
	@RequestMapping("query")
	public String query(HttpServletRequest request, HttpServletResponse response) {
		userComponentService.query(getParameterJSONObject());

		response.setContentType("text/html;charset=utf-8");

		return toJSONString(userComponentService.getResult(), true);
	}

	@ResponseBody
	@RequestMapping("count")
	public String count() throws IOException {
		userComponentService.count(getParameterJSONObject());

		return toJSONString(userComponentService.getResult());
	}

	public String insert() {
		/*userComponentService.insert(getParameterMap());

		setJSONObject(userComponentService.getResult());*/

		return "JSON_RESULT";
	}

	public String update() {
		/*userComponentService.update(getParameterMap());

		setJSONObject(userComponentService.getResult());*/

		return "JSON_RESULT";
	}

	public String delete() {
		/*userComponentService.delete(getParameterMap());

		setJSONObject(userComponentService.getResult());*/

		return "JSON_RESULT";
	}

	/* Getters & Setters
	================================================== */
	/*public void setUserComponentService(IUserComponentService userComponentService) {
		this.userComponentService = userComponentService;
	}*/

}
